<template>
	<view class="webview">
		<view style="width: 100%;height: 50px;background-color: #0079FF;"></view>
		<web-view :src="webView.src" @message="messageFn"></web-view>
	</view>
</template>
<script>
	let that,eventChannel
	import {
		mapGetters,
		mapMutations
	} from 'vuex'
	export default {
		components:{},
		computed: {
			...mapGetters(['userInfo', 'api']),
		},
		props: {},
		data() {
			return {
				sys:{
					statusBarHeight:0
				},
				webView:{
					src:'',
					data:''
				}
			}
		},
		onLoad(op) {
			//console.log(op);
			that = this
			eventChannel = this.getOpenerEventChannel();
			eventChannel.on('pagePramas',(data)=>{
				//console.log(data);
				this.processingData(data)
			})
			this.sys = uni.getSystemInfoSync();
		},
		onShow() {},
		methods: {
			processingData(data){
				this.webView.data={
					token:this.userInfo.token,
					baseUrl:uni.getStorageSync('baseUrl'),
					userInfo:this.userInfo
				}
				this.webView.src = data.url +'?data='+encodeURIComponent(JSON.stringify(this.webView.data))
				// #ifdef APP-PLUS
				var currentWebview = this.$scope.$getAppWebview()
				setTimeout(function() {
					let vw=currentWebview.children()[0]
					vw.setStyle({
						top:that.sys.statusBarHeight,
						height:that.sys.windowHeight-that.sys.statusBarHeight
					})
				}, 200); //如果是页面初始化调用时，需要延时一下
				//#endif
				
				// this.webView.src='/hybrid/html/pages/pdfPreview.html?data='+encodeURIComponent(JSON.stringify(this.webView))
			},
			messageFn:function(data){
				//console.log(data);
				
			}
		}

	}
</script>

<style lang="scss">
	.webview{
		
	}
</style>
